import request from '@/utils/request'
enum API {
   SPUURL = '/admin/product/',//获取spu
   TMURL = '/admin/product/baseTrademark/getTrademarkList',  //获取全部品牌的数据
   ALLATTR = '/admin/product/baseSaleAttrList', //全部销售属性接口
   IMAGELIST = '/admin/product/spuImageList/',//获取某一个已有的SPU照片墙的数据
   HAVESALE = '/admin/product/spuSaleAttrList/', //获取已有的SPU已有的销售属性
   SAVESPUINFO = '/admin/product/saveSpuInfo',//SPU添加
   UPDATESPUINFO = '/admin/product/updateSpuInfo',//修改SPU
   ATTR = '/admin/product/attrInfoList/',//平台属性
   ADDSKU = '/admin/product/saveSkuInfo',//添加SKU
   FINDSKU = '/admin/product/findBySpuId/',//获取SKU列表
   DELETESPU = '/admin/product/deleteSpu/',//删除SPU
}
//获取某一个三级分类下的全部SPU
export const reqSpuAttr = (page: number, limit: number, category3Id: string | number) => request.get(API.SPUURL + `${page}/${limit}?category3Id=${category3Id}`)

//获取全部品牌的数据
export const reqAllaTradeMark = () => request.get(API.TMURL)
//全部销售属性接口
export const reqAllAttr = () => request.get(API.ALLATTR)
//获取某一个已有的SPU照片墙的数据
export const reqImageList = (spuId: number) => request.get(API.IMAGELIST + spuId)
//获取已有的SPU已有的销售属性
export const reqHaveSale = (spuId: number) => request.get(API.HAVESALE + spuId)

//添加SPU或者修改已有的SPU
export const reqSaveAndUpdateInfo = (data: any) => {
   if (data.id) {
      request.post(API.UPDATESPUINFO, data)
   } else {
      request.post(API.SAVESPUINFO, data)
   }
}
//平台属性请求
export const reqAttrList = (category1Id: string | number, category2Id: string | number, category3Id: string | number) => request.get(API.ATTR + `${category1Id}/${category2Id}/${category3Id} `)
//添加sku
export const reqAddSku = (data: any) => request.post(API.ADDSKU, data)
//获取sku
export const reqFindSku = (spuId: number) => request.get(API.FINDSKU + spuId)
//删除spu
export const reqDeleteSpu = (spuId: Number) => request.delete(API.DELETESPU + spuId)


